package com.admin.utils.util;


import java.net.URLEncoder;

import javax.servlet.http.HttpServletResponse;

import org.apache.poi.ss.usermodel.Workbook;

public class EasyExcelToRequestUtil {
	
	/**
	 * 将excel的workbook导出
	 * @param req
	 * @param workbook
	 * @throws Exception 
	 */
	public static void reqExcel(HttpServletResponse rep,String fileName,Workbook workbook) throws Exception {
		fileName = URLEncoder.encode(fileName, "utf-8");
		rep.setContentType("application/vnd.ms-excel");
		rep.setHeader("content-disposition", "attachment;filename=" + fileName);		
		workbook.write(rep.getOutputStream());
		workbook.close();
	}

}
